<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>查询赎回申请信息</title>
    <jsp:include page="../../import.jsp" flush="true"/>
    <%--<jsp:include page="assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->--%>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>--------项目及还款信息--------</span>
            </div>
        </div>
        <div id="pageInTab" class="pageInTab">
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">合同编号</div>
                    <div class="field">
                        <span name="lsCntNo" id="lsCntNo">${redm.lsCntNo}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">承租人名称</div>
                    <div class="field">
                        <span>${redm.cstNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">第三方机构</div>
                    <div class="field">
                        <span>${redm.fundRasInsNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">租赁期数</div>
                    <div class="field">
                        <span name="fundRasInsNm" id="fundRasInsNm">${redm.lsPd}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合同总金额</div>
                    <div class="field">
                        <span>${redm.contAmt == null ? 0 : redm.contAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资总金额</div>
                    <div class="field">
                        <span>${redm.actLsAmt == null ? 0 : redm.actLsAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实际应收金额</div>
                    <div class="field">
                        <span>${redm.relActAmt == null ? 0 : redm.relActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">应收租金合计</div>
                    <div class="field">
                        <span>${redm.totalActAmt == null ? 0 : redm.totalActAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">实收租金合计</div>
                    <div class="field">
                        <span>${redm.totalRelRcptAmt == null ? 0 : redm.totalRelRcptAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期金额</div>
                    <div class="field">
                        <span>${redm.ovdAmt == null ? 0 : redm.ovdAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">罚息金额</div>
                    <div class="field">
                        <span>${redm.pnlAmt == null ? 0 : redm.pnlAmt/100}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">逾期天数</div>
                    <div class="field">
                        <span>${redm.ovdDay == null ? 0 : redm.ovdDay}</span>
                    </div>
                </div>
            </div>

            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>--------项目产品信息及放款信息--------</span>
                </div>
            </div>
            <!-- 列表显示块 -->
            <div id="ligergrid3" class="sq-grid"></div>
            <!--赎回原因-->
            <div class="sqPanel">
                <div class="sqPanel_head inL">
                    <span>--------赎回原因--------</span>
                </div>
            </div>
            <div class="fieldset1 tabel_col clearFix">
                <div class="fieldBox col_33">
                    <div class="label">赎回原因</div>
                    <div class="field">
                        <span>${redm.insRedmResonNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">具体原因</div>
                    <div class="field">
                        <span>${redm.insRedmDetailResonNm}</span>
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">其他原因</div>
                    <div class="field" style="width: 100%;">
                        <span>${redm.otherInsRedmReson}</span>
                    </div>
                </div>
                <!-- 附件显示 -->
                <div class="fieldBox col_100">
                    <div style="width: 98%; margin-left: 1%;">
                        <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecList.jsp" flush="true" >
                            <jsp:param name="pkId" value="${pkId}"/>
                            <jsp:param name="tabNm" value="${tabNm}"/>
                        </jsp:include>
                    </div>
                </div>
            </div>
            <!--资方赎回信息-->
            <c:if test="${isShowInsRedmInterfaceInfo == 1 && redm.insPayTime != null}">
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------资方赎回接口信息--------</span>
                    </div>
                </div>
                <!-- 资方赎回接口显示块 -->
                <div id="ligergrid2" class="sq-grid"></div>
            </c:if>
            <form id="insRedmApplyForm">
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------资方赎回信息--------</span>
                    </div>
                </div>
                <div class="fieldset1 tabel_col clearFix">
                    <div class="fieldBox col_33">
                        <div class="label">是否已经线下赎回</div>
                        <div class="field">
                            <span>
                                <c:if test="${redm.offlineSettle == 1}">
                                    是
                                </c:if>
                                <c:if test="${redm.offlineSettle == 0}">
                                    否
                                </c:if>
                            </span>
                        </div>
                    </div>
                    <c:if test="${redm.offlineSettle == 1}">
                        <div class="fieldBox col_33" id="insRedmTmDiv">
                            <div class="label">线下赎回时间</div>
                            <div class="field">
                                <span id="insRedmTm">${redm.insRedmTm}</span>
                            </div>
                        </div>
                    </c:if>
                    <div class="fieldBox col_33" id="redmTotalAmtDiv">
                        <div class="label">赎回金额合计</div>
                        <div class="field">
                            <span>${redm.redmTotalAmt == null ? 0 : redm.redmTotalAmt/100}</span>                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">赎回本金</div>
                        <div class="field">
                            <span>${redm.redmPrinAmt == null ? 0 : redm.redmPrinAmt/100}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">赎回利息</div>
                        <div class="field">
                            <span>${redm.redmIntAmt == null ? 0 : redm.redmIntAmt/100}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">赎回罚息</div>
                        <div class="field">
                            <span>${redm.redmPnlAmt == null ? 0 : redm.redmPnlAmt/100}</span>
                        </div>
                    </div>
                    <!--新增三方放款状态判断-->
                    <div class="fieldBox col_33">
                        <div class="label">资方放款结果</div>
                        <div class="field">
                                <c:if test="${redm.payerStsCd == '0'}">
                                    <span>未申请</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '1'}">
                                    <span>申请中</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '2'}">
                                    <span>放款通过</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '3'}">
                                    <span>拒绝放款</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '4'}">
                                    <span>已赎回</span>
                                </c:if>
                                <c:if test="${redm.payerStsCd == '5'}">
                                    <span>已赎回结清</span>
                                </c:if>
                        </div>
                    </div>

                    <!--新增字段-->
                    <div class="fieldBox col_33">
                        <div class="label">是否上报征信(融担)</div>
                        <div class="field">
                            <span>
                                <c:if test="${redm.isSubmitCreditRD == 2}">
                                    是
                                </c:if>
                                <c:if test="${redm.isSubmitCreditRD == 1}">
                                    否
                                </c:if>
                            </span>
                        </div>
                    </div>

                    <div class="fieldBox col_33">
                        <div class="label">回购主体</div>
                        <div class="field">
                            <span>${redm.suretySubjectNm}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">付款方式</div>
                        <div class="field">
                            <c:if test="${repayMode == '0'}">
                                <span>资方划扣</span>
                            </c:if>
                            <c:if test="${repayMode == '1'}">
                                <span>拜特打款</span>
                            </c:if>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">我司赎回付款账户</div>
                        <div class="field">
                            <span>${redmPaymentAccount.accNm} ${redmPaymentAccount.accNum}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">资方赎回收款账户</div>
                        <div class="field">
                            <span>${redmPayeeAccount.accNm} ${redmPayeeAccount.accNum}</span>
                        </div>
                    </div>
                    <div class="fieldBox col_33">
                        <div class="label">打款备注</div>
                        <div class="field">
                            <span>${redm.paymentReason}</span>
                        </div>
                    </div>
                    <!-- hide data -->
                    <div class="fieldBox col_100" style="display: none;">
                        <div class="field">
                            <input name="prjId" id="prjId" type="text" class="ui-textbox" value="${redm.prjId}">
                        </div>
                    </div>
                </div>
                <div class="sqPanel">
                    <div class="sqPanel_head inL">
                        <span>--------来款核销信息--------</span>
                    </div>
                </div>
                <div id="vfGrid" class="sq-grid"></div>
            </form>
        </div>
    </div>
</div>

<script type="text/javascript">
    var repayGrid = null;
    var payerStsCd = '${redm.payerStsCd}';
    var insPayTime = '${redm.insPayTime}';
    var isShowInsRedmInterfaceInfo = '${isShowInsRedmInterfaceInfo}';
    var vfGrid = null;
    $(function () {
        initGrid();
        if(isShowInsRedmInterfaceInfo == '1' && insPayTime != '' && insPayTime != null && insPayTime != undefined){
            initGrid1();
        }
        setFormatDateValue();
        if(payerStsCd == '2' || payerStsCd == '4' || payerStsCd == '5'){
            if(insPayTime != '' && insPayTime != null && insPayTime != undefined){
                initIsDedu();
            }

        }
        var insRedmApplyForm = liger.get("insRedmApplyForm");
        var ligerForm = $("#insRedmApplyForm").ligerForm({
            validate: true
        });
        initVfGrid();
    });

    // 初始化来款核销信息列表
    function initVfGrid() {
        var paySchId = '${redm.paySchId}';
        vfGrid = $("#vfGrid").ligerGrid({
            // data: data,
            method: 'get',
            url: '<%=path%>/institution/prjinsredminfo/initVfInfo.do?paySchId=' + paySchId,
            columns: [
                {display: '资金编号', name: 'code', width: 180, enabledSort: true},
                {display: '来款时间', name: 'acceptDate', width: 150, enabledSort: true,render: renderDate},
                {
                    display: '合计金额（元）', name: 'totalAmt', width: 150, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        if (value == null || value === '') {
                            return '&yen;0.00';
                        } else {
                            return '&yen;' + FormatMoney(rowdata.totalAmt / 100);
                        }
                    }
                },

                {
                    display: '本金（元）', name: 'capAmt', width: 150, enabledSort: true,
                    render:function(rowdata,index,value){
                        if (value == null || value === '') {
                            return '&yen;0.00';
                        } else {
                            return '&yen;' + FormatMoney(rowdata.capAmt / 100);
                        }
                    }
                },
                {
                    display: '利息（元）', name: 'intrAmt', width: 150, enabledSort: true,
                    render:function(rowdata,index,value){
                        if (value == null || value === '') {
                            return '&yen;0.00';
                        } else {
                            return '&yen;'+FormatMoney(rowdata.intrAmt/100);
                        }
                    }
                },
                {
                    display: '罚息（元）', name: 'penaltyAmt', width: 150, enabledSort: true,
                    render:function(rowdata,index,value){
                        if (value == null || value === '') {
                            return '&yen;0.00';
                        } else {
                            return '&yen;'+FormatMoney(rowdata.penaltyAmt/100);
                        }
                    }
                },
                {
                    display: '是否冲红', name: 'isRevert', width: 80, enabledSort: true,
                    render:function(rowdata,index,value){
                        if (1 == rowdata.isRevert) {
                            return '是';
                        } else {
                            return '否';
                        }
                    }
                },
                {display: '冲红时间', name: 'revertDt', width: 150, enabledSort: true, render: renderDate}
            ],
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            isScroll: false,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
        // vfGrid.setHeight(100);
        vfGrid.options.isSingleCheck = true;//列表是否为单选
    }

    //设置日期值
    function setFormatDateValue() {
        var deduProveTm = $("#deduProveTm").text();
        if (deduProveTm) {
            var deduProveTm = DateUtils.formatDate(new Date(deduProveTm), DateUtils.YYYY_MM_DD);
            $("#deduProveTm").text(deduProveTm);
        }
        var insRedmTm = $("#insRedmTm").text();
        if (insRedmTm) {
            var insRedmTm = DateUtils.formatDate(new Date(insRedmTm), DateUtils.YYYY_MM_DD);
            $("#insRedmTm").text(insRedmTm);
        }
    }

    /**
     * 是否已扣款选择
     */
    function initIsDedu(){
        var insIsDedu = $("#insIsDedu").val();
        if(insIsDedu == '0'){
            $("#diffAmtTypDiv").attr("style","display:block;");
            $("#diffAmtDiv").attr("style","display:block;");
            $("#deduProveTmDiv").attr("style","display:none;");
            $("#deduProveFileDiv").attr("style","display:none;");

        }else if(insIsDedu == '1'){
            $("#diffAmtTypDiv").attr("style","display:none;");
            $("#diffAmtDiv").attr("style","display:none;");
            $("#deduProveTmDiv").attr("style","display:block;");
            $("#deduProveFileDiv").attr("style","display:block;");
        }
    }
    //初始化列表
    function initGrid() {
        var prjId = $("#prjId").val();
        $("#ligergrid3").ligerGrid({
            // data: data,
            method: 'get',
            url: '<%=path%>/institution/prjinsredminfo/initPrjDtlInfo.do?prjId=' + prjId,
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, enabledSort: true,},
                {
                    display: '我司是否已放款', name: 'isOCPay', width: 200, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "";
                        if (rowdata.isOCPay == 0) {
                            h = "否";
                        }
                        if (rowdata.isOCPay == 1) {
                            h = "是";
                        }
                        return h;
                    }
                },
                {display: '设备名', name: 'prdNm', width: 200, enabledSort: true,},
                {display: '车辆型号', name: 'prdMdl', width: 200, enabledSort: true},
                {display: '合格证编号', name: 'certNo', width: 200, enabledSort: true},
                {display: 'VIN', name: 'vin', width: 200, enabledSort: true}
            ],
            onAfterShowData: function (e) {
                var rows = e.rows;
                var i = 0;
                for (var index in rows) {
                    i += rows[index].arAmt;
                }
                $("#arAmts").text(i);
            },
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '100%',
            heightDiff: -2,
            isScroll: true,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
        repayGrid = liger.get("ligergrid3");
        //grid.setHeight(100);
        repayGrid.options.isSingleCheck = true;//列表是否为单选
    }

    //初始化资方赎回列表
    function initGrid1() {
        var prjId = $("#prjId").val();
        var paySchId = '${redm.paySchId}';
        var data = 'prjId='+prjId+'&paySchId='+paySchId+'&payerStsCd='+payerStsCd;

        grid1 = $("#ligergrid2").ligerGrid({
            method: 'get',
            url: '<%=path%>/institution/prjinsredminterfaceinfo/initInsRedmInterfaceInfoList.do?'+data,
            columns: [
                {display: '支付表号', name: 'paySchNo', width: 200, enabledSort: true,},
                {display: '时间', name: 'crtTm', width: 200, enabledSort: true,render: renderDate},
                {display: '赎回金额合计', name: 'redmAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.redmAmt;

                        }
                    }
                },
                {display: '本金', name: 'principalAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.principalAmt;

                        }
                    }
                },
                {display: '利息', name: 'interestAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.interestAmt;

                        }
                    }
                },
                {display: '罚息', name: 'penaltyAmt', width: 200, enabledSort: true,
                    render:function(rowdata,index,value){
                        if(value == null || value === ''){
                            return '';
                        }else{
                            return '&yen;'+rowdata.penaltyAmt;

                        }
                    }
                },
                {display: '动作', name: 'operationType', width: 200, enabledSort: true,
                    render: function (rowdata, rowindex, value, column) {
                        var h = "";
                        if (rowdata.operationType == '0') {
                            h = '试算';
                        }else if(rowdata.operationType == '1'){
                            h = '赎回';
                        }
                        return h;
                    }
                }
            ],
            onAfterShowData: function (e) {
            },
            usePager: false,//是否有分页便签
            root: 'rows',
            record: 'total',
            hideLoadButton: false,
            width: '100%',
            height: '45%',
            heightDiff: -2,
            isScroll: false,//是否有滚动条
            checkbox: false,//列表是否有选择框
            enabledEdit: true,//是否能编辑
            rownumbers: true//列表是否有行号
        });
    }

    //格式化时间
    function renderDate(rowdata, index, value) {
        var dateStr = "";
        if (null != value && value != '') {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

    //格式化为人民币格式
    function renderAmt(rowdata, rowindex, value) {
        if(value == null || value == undefined ){
            return '';
        }
        var h = "￥" + FormatMoney(value);
        return h;
    }


</script>
</body>
</html>